<?php

namespace JLPay\Models\Trans\Common;

use JLPay\Models\BaseRequest;

/**
 * 获取OpenID请求模型
 */
class GetOpenidRequest extends BaseRequest
{
    /**
     * API URL
     */
    public const API_URL = "/open/trans/getopenid";

    /**
     * @var string|null 商户号
     */
    private ?string $mchId = null;

    /**
     * @var string|null 交易类型
     */
    private ?string $payType = null;

    /**
     * @var string|null 授权码
     */
    private ?string $authCode = null;

    /**
     * @var string|null 子商户appid
     */
    private ?string $subAppid = null;

    /**
     * @var string|null 应用标识
     */
    private ?string $appUpIdentifier = null;

    /**
     * @var string|null 终端设备号
     */
    private ?string $deviceInfo = null;

    /**
     * @var string|null 商户IP
     */
    private ?string $mchCreateIp = null;

    /**
     * 设置商户号
     *
     * @param string $mchId 商户号
     * @return $this
     */
    public function setMchId(string $mchId): self
    {
        $this->mchId = $mchId;
        return $this;
    }

    /**
     * 获取商户号
     *
     * @return string|null 商户号
     */
    public function getMchId(): ?string
    {
        return $this->mchId;
    }

    /**
     * 设置交易类型
     *
     * @param string $payType 交易类型
     * @return $this
     */
    public function setPayType(string $payType): self
    {
        $this->payType = $payType;
        return $this;
    }

    /**
     * 获取交易类型
     *
     * @return string|null 交易类型
     */
    public function getPayType(): ?string
    {
        return $this->payType;
    }

    /**
     * 设置授权码
     *
     * @param string $authCode 授权码
     * @return $this
     */
    public function setAuthCode(string $authCode): self
    {
        $this->authCode = $authCode;
        return $this;
    }

    /**
     * 获取授权码
     *
     * @return string|null 授权码
     */
    public function getAuthCode(): ?string
    {
        return $this->authCode;
    }

    /**
     * 设置子商户appid
     *
     * @param string $subAppid 子商户appid
     * @return $this
     */
    public function setSubAppid(string $subAppid): self
    {
        $this->subAppid = $subAppid;
        return $this;
    }

    /**
     * 获取子商户appid
     *
     * @return string|null 子商户appid
     */
    public function getSubAppid(): ?string
    {
        return $this->subAppid;
    }

    /**
     * 设置应用标识
     *
     * @param string $appUpIdentifier 应用标识
     * @return $this
     */
    public function setAppUpIdentifier(string $appUpIdentifier): self
    {
        $this->appUpIdentifier = $appUpIdentifier;
        return $this;
    }

    /**
     * 获取应用标识
     *
     * @return string|null 应用标识
     */
    public function getAppUpIdentifier(): ?string
    {
        return $this->appUpIdentifier;
    }

    /**
     * 设置终端设备号
     *
     * @param string $deviceInfo 终端设备号
     * @return $this
     */
    public function setDeviceInfo(string $deviceInfo): self
    {
        $this->deviceInfo = $deviceInfo;
        return $this;
    }

    /**
     * 获取终端设备号
     *
     * @return string|null 终端设备号
     */
    public function getDeviceInfo(): ?string
    {
        return $this->deviceInfo;
    }

    /**
     * 设置商户IP
     *
     * @param string $mchCreateIp 商户IP
     * @return $this
     */
    public function setMchCreateIp(string $mchCreateIp): self
    {
        $this->mchCreateIp = $mchCreateIp;
        return $this;
    }

    /**
     * 获取商户IP
     *
     * @return string|null 商户IP
     */
    public function getMchCreateIp(): ?string
    {
        return $this->mchCreateIp;
    }

    /**
     * 转换为数组格式
     *
     * @return array 数组格式的数据
     */
    public function toArray(): array
    {
        $data = parent::toArray();
        $data = array_merge($data, [
            'mch_id' => $this->mchId,
            'pay_type' => $this->payType,
            'auth_code' => $this->authCode,
            'sub_appid' => $this->subAppid,
            'app_up_identifier' => $this->appUpIdentifier,
            'device_info' => $this->deviceInfo,
            'mch_create_ip' => $this->mchCreateIp
        ]);

        return $data;
    }
} 